import lejos.nxt.*;
import lejos.nxt.comm.*;
import java.io.*;


public class CommTest 
{
	
	public static void main( String[] args) throws Exception { 
		// LCD.drawString("right BT",0, 0) 
	}
	
	public void writeToRobot() {
		// init. connections & data streams
		NXTConnection connection = null;
		connection = Bluetooth.waitForConnection();
		DataInputStream dis = connection.openDataInputStream();
		DataOutputStream dos = connection.openDataOutputStream();
		
		// try to write
		try {
			int n = dis.readInt();
			LCD.drawInt(n,7,0,1);
	        dos.writeInt(-n);
	        
	        // flush, clear and close connections
	        dos.flush();
	        LCD.clear();
			dis.close();
		    dos.close();
		} catch (IOException e) {
			// TODO Auto-generated catch block
		}
		
	}
	
	public void writeToRobot(int n) {
		// init. connections & data streams
		NXTConnection connection = null;
		connection = Bluetooth.waitForConnection();
		DataOutputStream dos = connection.openDataOutputStream();
		
		// try to write
		try {
			LCD.drawInt(n,7,0,1);
	        dos.writeInt(-n);
	        
	        // flush, clear and close connections
	        dos.flush();
	        LCD.clear();
		    dos.close();
		} catch (IOException e) {
			// TODO Auto-generated catch block
		}
		
		
	}
}